package com.zhangj.alljuc.threadpool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @ClassName MyThreadPoolTest2
 * @Description
 * @Author zhangjie
 * @Date 2022/3/8 12:57
 * @Version 1.0
 */
public class MyThreadPoolTest2 {

    public static void main(String[] args) {

        //ExecutorService executorService = Executors.newFixedThreadPool(5);
        //ExecutorService executorService = Executors.newSingleThreadExecutor();
        ExecutorService executorService = Executors.newCachedThreadPool();


        try {
            for (int i = 1; i <= 10; i++) {
                executorService.execute(() -> {
                    System.out.println(Thread.currentThread().getName() + "正在办理业务");
                });

               // TimeUnit.SECONDS.sleep(3);

            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            executorService.shutdown();
        }

    }

}
